const { WebSocketServer } = require("ws")
const wss = new WebSocketServer({
  port:8000
})
wss.on("connection",(ws,req)=>{
  ws.on("message",data=>{
    const msgObj = JSON.parse(data)
    wss.clients.forEach(client=>{
      if(client.readyState === 1){
        //已经连接状态
        client.send(JSON.stringify(msgObj))
      }
    })
  })

})